package com.KaraoKit;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;

import org.apache.http.util.ByteArrayBuffer;

public class Connectivity {

	/**
	 * retreives the appropriate ".lrc" file for the specific song from the
	 * internet, and downloads it to a dedicated folder.
	 * @param searchValue - the name of the song
	 * @return the downloaded file 
	 */
	File getLyricsFromWeb(String searchValue){
		String myString;
		try{
			URL url = new URL("http://www.songmeanings.net/query/?q=" +
					searchValue + "&type=song");
			URLConnection conn = url.openConnection(); 
			InputStream is = conn.getInputStream(); 
			BufferedInputStream bis = new BufferedInputStream(is);
			OutputStream os
			BufferedOutputStream bos = new BufferedOutputStream()
			 ByteArrayBuffer baf = new ByteArrayBuffer(50);
	         int current = 0;
	         while((current = bis.read()) != -1){
	              baf.append((byte)current);
	         } 
	         myString = new String(baf.toByteArray()); 
		}
		catch (IOException ioe)
		{
			 myString = ioe.getMessage(); 
		}
		return null;
	}

	/**
	 * retreives the appropriate ".mid" file of the specific song from the
	 * internet, and downloads it to a dedicated folder.
	 * @param searchValue - the name of the song
	 * @return the downloaded file 
	 */
	File getMIDIFromWeb(String searchValue){
		return null;
	}

	/**
	 * retreives the appropriate ".lrc" file of the specific song from the 
	 * dedicated folder in the phone, and downloads it to a dedicated folder.
	 * @param searchValue - the name of the song
	 * @return the downloaded file 
	 */
	File getLyricsFromLocal(String searchValue){
	
		return null;
	}

	/**
	 * retreives the appropriate ".mid" file of the specific song from the 
	 * dedicated folder in the phone, and downloads it to a dedicated folder.
	 * @param searchValue - the name of the song
	 * @return the downloaded file 
	 */
	File getMIDIFromLocal(String searchValue){
		return null;
	}
	/**
	 * @param searchValue - the name of the file
	 * @return true iff a file "searchValue.lrc" exists in the dedicated folder
	 */
	boolean isLyricExists(String searchValue){
		return false;
	}
	/**
	 * @param searchValue - the name of the file
	 * @return true iff a file "searchValue.mid" exists in the dedicated folder
	 */
	boolean isMIDIExists(String searchValue){
		return false;
	}



}
